package ru.edu.usu.cs.bubbles.engine.box2d.colliders;

import ru.edu.usu.cs.bubbles.engine.GameEntity;
import ru.edu.usu.cs.bubbles.engine.GameWorld;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Fixture;

public class Box2dFanCollider extends Collider {
	public Box2dFanCollider(GameWorld world) {
		super(world);
	}

	@Override
	public void processCollision(Fixture myFixture, Fixture otherFixture) {
		if(myFixture.isSensor()) {
			Vector2 otherFixturePos = otherFixture.getBody().getPosition();
			Vector2 force = myFixture.getBody().getPosition()
								.sub(otherFixturePos)
								.mul(-1);
			otherFixture.getBody().applyForce(force, otherFixturePos);
		}
		else {
			world.destroyEntity((GameEntity) otherFixture.getGameEntity());
		}
	}
}
